<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
     <title>认证</title>
     <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/reset.css">
     <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/sign in scss.css">
     <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <script src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.1.min.js"></script>
</head>
<body>
	<div class="box">
    	<div class="nav">
    		<img src="<?php echo IMG_PATH ?>bdkd/img/图@2x.png"/>
    	</div>
    	<div class="sj">
    		<span class="86">+86 <input id="inp1" class="ipt-one" type="text"  value="请输入手机号"></span>
    	</div>
    	
    	<div class="float">
        	<input id="inp2" style="box-shadow:none;" class="ipt-two" type="text" value="请输入验证码" class="inp2"/>
        	<div id="btn" onclick="sendemail()"/>获取验证码</div>
    	</div>
       
    	<a style="text-decoration:none;" href="#"><div id="inp3" class="ipt-three"/>认证</div></a>
	</div>
<!-- <p><a style=" display:inline-block;width: 4rem; height: 2rem; border: 1px solid #006600;" href="javascript:window.location.reload()">刷新</a></p> -->
</body>
<script>
    var countdown=60;
    function sendemail(){
        var obj = $("#btn");
        var phone = $("#inp1").val();
        settime(obj);
        $.ajax({
            // 请求发送方式
            type: 'post',
            // 验证文件
            url: '<?php echo SITE_PATH ?>work/buser/sendCode',
            dataType:'json',
            // 用户输入的帐号验证码
            data: {
                'phone': phone
            },
            success: function(data){
//                console.log(data);
//                if(data.result==1){
//                    alert('获取验证码成功!');
//                }else {
//                    alert('获取验证码失败!');
//                }
            },
            error: function(){
                alert('获取验证码失败!');
            }

        })



    }
    function settime(obj) { //发送验证码倒计时
        if (countdown == 0) {
            obj.attr('disabled',false);
            //obj.removeattr("disabled");
            obj.val("重新获取");
            countdown = 60;
            return;
        } else {
            obj.attr('disabled',true);
            obj.val("倒计时" + countdown + "s");
            countdown--;
        }
        setTimeout(function() {
                settime(obj) }
            ,1000)
    }


    $('.ipt-one').click(function(){
        $('.ipt-one').val('').css('color','#333');
    })
    $('.ipt-two').click(function(){
        $('.ipt-two').val('').css('color','#333');
    })
    $('.ipt-three').click(function(){
        $('.ipt-three').css('background','#1293e1');
    })
    $("#inp3").on("click",function () {
        var phone = $("#inp1").val();
        var code = $("#inp2").val();

        //URL 写上
        $.ajax({
            // 请求发送方式
            type: 'post',
            // 验证文件
            url: '<?php echo SITE_PATH ?>work/buser/login',
            dataType:'json',
            // 用户输入的帐号验证码
            data: {
                'phone': phone,
                'code': code
            },
            success: function(data){
                //console.log('<?php echo SITE_PATH ?>work/bpost/success');
                if(data.result==1){
//                    alert("登录成功跳转至首页!");
                    //跳转
                    window.location.href = '<?php echo SITE_PATH ?>work/bpost/main';
                }else{
                    alert(data.msg);
                }
            },
            error: function(){
                alert('登录失败0!');
            }

        })
    })
</script>
</html>